$(function () {
    layer.config({
        path: '/layer/'
    });
    $(function () {
        // 请求数据
        setTimeout(function () {
            layer.load(1, {shade: [0.3, '#000']});
        },100);

        // 数据
        setTimeout(function () {
            $('.progress').load('http://www.pulife.top:9101/getvalue/1163562')
            $('.bottom1 span').text(66);
            init(99);
            layer.closeAll();
        },500);

        //初始化事件
        function init(r) {
            $.guanghuan(r)
        }


        //光环效果
        $.extend({
           guanghuan:function (r) {
               var conf = {
                   left:{
                       dom:$('.left'),
                       data:[180,167,144,120,95,71,48,24,0]
                   },
                   right:{
                       dom:$('.right'),
                       data:[180,166,144,120,96,72,47,23,0]
                   }
               };
               var stepRight = conf.right.data[0];
               var stepLeft = conf.left.data[0];
               var step = _.ceil(16*r*0.01);
               var leftN,rightN;
               if(step <= 8){
                   rightN = step;
                   leftN = 0;
               }else{
                   rightN = 8;
                   leftN = step - 8;
               }
               console.log(step,step <= 8,rightN,leftN);

               var timer = setInterval(function () {
                    if(stepRight > conf.right.data[rightN] ){
                        stepRight--;
                        conf.right.dom.css('transform','rotate(-' + stepRight +'deg)');
                    }else if(stepLeft > conf.left.data[leftN]){
                        stepLeft--;
                        conf.right.dom.addClass('r100');
                        conf.right.dom.css('transform','rotate(-' + stepLeft +'deg)');
                        conf.left.dom.css('transform','rotate(-' + stepLeft +'deg)');
                    }else {
                        clearInterval(timer);
                    }

               },5);
                console.log(r);
           }
        })
    })
});